﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Cinser.Common
{
    /// <summary>
    /// 声音操作公共类
    /// </summary>
    public class SoundOperation
    {

        /// <summary>
        /// PlayingMedia：播放给定路径的声音
        /// </summary>
        /// <param name="mediaPath">声音文件路径</param>
        /// <returns>return null:播放完成。return Exception:播放异常，返回异常消息。</returns>
        public static Exception PlayingMedia(string mediaPath)
        {
            try
            {
                WMPLib.WindowsMediaPlayerClass MediaPlayer;
                MediaPlayer = new WMPLib.WindowsMediaPlayerClass();
                MediaPlayer.URL = mediaPath;
                MediaPlayer.play();
                return null;
            }
            catch (Exception ex)
            {
                return ex;
            }
        }
    }
}
